package pt.iscte.dcti.pr.dbo;

import java.sql.Connection;
import java.sql.DriverManager;

public class ConnectDataBase {

	Connection conn = null;
	String url;
	String driver;
	String userName;
	String password;

	public Connection mySqlConnection() {

		url = "jdbc:mysql://localhost:3306/testingbd";
		driver = "com.mysql.jdbc.Driver";
		userName = "root";
		password = "root";

		try {
			Class.forName(driver).newInstance();
			conn = DriverManager.getConnection(url, userName, password);
			System.out.println("Connected.");

		} catch (Exception e) {
			e.printStackTrace();
		}
		return conn;
	}
	
	public void closeConnection(Connection conn){
        try{
              conn.close();
        }catch(Exception e){
              e.getMessage();
        }
  }


}
